package com.stream.controller;

import com.stream.model.entity.SysLogEntity;
import com.stream.service.SysLogService;
import com.stream.utils.PageUtils;
import com.stream.utils.Query;
import com.stream.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by yebaokang on 2017/6/16.
 */
@RestController
@RequestMapping("/sys/log")
public class SysLogController extends AbstractController {

    @Autowired
    private SysLogService sysLogService;

    /**
     * 查询日志列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:log:list")
    public R list(@RequestParam Map<String, Object> params) {
        Query query = new Query(params);
        List<SysLogEntity> logList = sysLogService.queryList(query);
        int total = sysLogService.queryTotal(query);

        PageUtils page = new PageUtils(logList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", page);
    }


}
